<?php
/**
 * Template Name: Pitches
 */
get_header(); ?>

<div class="container">
    <? while (have_posts()) : the_post(); ?>

    <?
    $custom = get_fields($post->ID);
    $currentID = $post->ID;
    //var_dump($fields);
    ?>

    <div>
        <h1><? the_title() ?></h1>

        <div class="row-fluid">
            <div class="span8">
                <?
                $pitch_query = new WP_Query(array('post_type' => 'pitch', 'showposts' => 100));
                while ($pitch_query->have_posts()) : $pitch_query->the_post();

                    $pitchFields = get_fields($pitch_query->post->ID);
                    ?>

                    <div class="card grey search-result clearfix" style="display: block;">
                        <a href="<? echo get_permalink($pitch_query->post->ID) ?>" class="btn btn-small btn-primary pull-right" style="margin-top:-5px;margin-bottom:-15px;clear:both"><span style="font-weight: 800">View »</span></a>

                        <h3 style=" margin-bottom: 5px;">
                            <a href="<? echo get_permalink($pitch_query->post->ID) ?>" class="result-title"><? echo $pitchFields['pid'] . ', ' . get_field('name', getVenueID($pitch_query->post->ID)) ?></a>
                        </h3>

                        <a href="<? echo get_permalink($pitch_query->post->ID) ?>"
                           style="width:254px;display: block;float: left;margin-bottom: -15px;">
                            <? printImage($pitchFields['image_1'], $custom['name'] . ' - ' . $pitchFields['pid'], 'pitch-main') ?>
                        </a>

                        <table class="table table-striped table-condensed table-bordered" style="width: 355px;float: right;margin-bottom:0;">
                            <tbody>
                            <tr>
                                <td><strong>Size</strong></td>
                                <td><? echo $pitchFields['size']; ?></td>
                            </tr>
                            <tr>
                                <td><strong>Surface</strong></td>
                                <td><? echo $pitchFields['surface']; ?></td>
                            </tr>
                            <tr>
                                <td><strong>Floodlit</strong></td>
                                <td><? echo $pitchFields['floodlit']; ?></td>
                            </tr>
                            <tr>
                                <td><strong>Indoor</strong></td>
                                <td><? echo $pitchFields['indoor']; ?></td>
                            </tr>
                            </tbody>
                        </table>

                    </div>

                    <?
                endwhile;
                ?>

            </div>
            <div class="span4">
            </div>
        </div>


    </div>

    <? endwhile; ?>
</div>

<?php get_footer(); ?>

<script type="text/javascript"
        src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB-k-7b00P-IEkcvnNmQekON1RL9SVPSQI&sensor=false"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/PITCHWISE.map.js"></script>

<script>
    $(function () {
        var options = {};
        var geoMap = new PITCHWISE.map(options);


        PW.pitch.init();
    });
</script>